package com.cssl.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerContainerFactory;

import javax.jms.ConnectionFactory;

@Configuration
public class ActiveMQConfig {
    /**
     * @JmsListener注解默认只接收yml配置的消息类型,如果要同时接收topic消息,需要设置containerFactory
     * 针对消费者配置
     */
    @Bean("topicContainer")
    public JmsListenerContainerFactory<?> topicListenerContainer(ConnectionFactory connectionFactory) {
        DefaultJmsListenerContainerFactory jcf = new DefaultJmsListenerContainerFactory();
        jcf.setConnectionFactory(connectionFactory);
    	jcf.setPubSubDomain(true);
        return jcf;
    }
}